/// <license>
/// Copyright (c) 2002-2008, DotNetNuke Corporation
/// All rights reserved
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
/// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
/// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
/// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
/// of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
/// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
/// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
/// DEALINGS IN THE SOFTWARE.
/// </license>

#region Using Statements

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Xml.Serialization;

using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.UI.WebControls;
using DotNetNuke.ModuleToolkit.Framework;

#endregion

namespace DotNetNuke.Modules.Articles.Framework
{
    /// -----------------------------------------------------------------------------
    /// <summary>
    /// The SectionInfo Class provides the Section Business Object
    /// </summary>
    /// <history>
    /// 	[cnurse]	01/31/2006	Created
    ///     [cnurse]    04/01/2006  Added SectionSkin and DefaultImageDirectory properties
    /// </history>
    /// -----------------------------------------------------------------------------
    [XmlRoot("section")]
    public class SectionInfo : EntityBase, IHydratable
    {

        #region Private Members

        private int _DefaultImageDirectory = Null.NullInteger;
        private string _Name = Null.NullString;
        private int _ParentSectionId = Null.NullInteger;
        private int _SectionId = Null.NullInteger;
        private string _SectionSkin = Null.NullString;

        #endregion

        #region Public Properties

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets and sets the DefaultImageDirectory of the Section
        /// </summary>
        /// <history>
        /// 	[cnurse]	01/31/2006	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        [Bindable(false),
        SortOrder(3),
        Editor("DotNetNuke.ModuleToolkit.Controls.FolderEditControl, DotNetNuke.ModuleToolkit",
            "DotNetNuke.UI.WebControls.EditControl"),
        XmlIgnore()]
        public int DefaultImageDirectory
        {
            get { return _DefaultImageDirectory; }
            set { _DefaultImageDirectory = value; }
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets and sets the Name of the Section
        /// </summary>
        /// <history>
        /// 	[cnurse]	01/31/2006	Created
        /// </history>
        /// -----------------------------------------------------------------------------        
        [Bindable(false),
        ControlStyle("NormalTextBox", "200px"),
        Required(true), 
        SortOrder(0), 
        XmlElement("name")]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets and sets the Id of the Parent Section
        /// </summary>
        /// <history>
        /// 	[cnurse]	02/09/2006	Created
        /// </history>
        /// -----------------------------------------------------------------------------        
        [Bindable(false), 
        SortOrder(1),
        Editor("DotNetNuke.Modules.Articles.UI.Editors.SectionEditControl, DotNetNuke.Modules.Articles", 
            "DotNetNuke.UI.WebControls.EditControl"),
        XmlIgnore()]
        public int ParentSectionId
        {
            get { return _ParentSectionId; }
            set { _ParentSectionId = value; }
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets and sets the Id of the Section
        /// </summary>
        /// <history>
        /// 	[cnurse]	01/31/2006	Created
        /// </history>
        /// -----------------------------------------------------------------------------        
        [Browsable(false), XmlIgnore()]
        public int SectionId
        {
            get { return _SectionId; }
            set { _SectionId = value; }
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets and sets the Skin to use for the Section
        /// </summary>
        /// <history>
        /// 	[cnurse]	04/01/2006	Created
        /// </history>
        /// -----------------------------------------------------------------------------        
        [Bindable(false),
        SortOrder(2),
        Editor("DotNetNuke.Modules.Articles.UI.Editors.SkinEditControl, DotNetNuke.Modules.Articles",
           "DotNetNuke.UI.WebControls.EditControl"),
        XmlIgnore()]
        public string SectionSkin
        {
            get { return _SectionSkin; }
            set { _SectionSkin = value; }
        }

        #endregion

        #region IHydratable Members

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets and sets the KeyID of the Section
        /// </summary>
        /// <remarks>The KeyID is the unique identifier, used by the CBO class to build
        /// a Dictionary of Sections</remarks>
        /// <history>
        /// 	[cnurse]	07/04/2007	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        [Browsable(false),
        XmlIgnore()]
        public int KeyID
        {
            get { return SectionId; }
            set { SectionId = value; }
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Hydrates a Section from a DataReader representing the Section
        /// </summary>
        /// <param name="source">The Data Reader containing the values to use to fill the Section.</param>
        /// <history>
        /// 	[cnurse]	12/22/2006	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void Fill(IDataReader source)
        {
            //Hydrate the EntityBase Properties
            base.FillInternal(source);

            SectionId = Convert.ToInt32(Null.SetNull(source["SectionID"], SectionId));
            ParentSectionId = Convert.ToInt32(Null.SetNull(source["ParentSectionID"], ParentSectionId));
            Name = Convert.ToString(Null.SetNull(source["Name"], Name));
            DefaultImageDirectory = Convert.ToInt32(Null.SetNull(source["DefaultImageDirectory"], DefaultImageDirectory));
            SectionSkin = Convert.ToString(Null.SetNull(source["SectionSkin"], SectionSkin));
        }

        #endregion

    }
}
